﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace QYmall.Core.Model.ViewModels
{
    /// <summary>
    /// 优惠券(显示)
    /// </summary>
    public class ShopCouponDto : ShopCouponEditDto
    {
        /// <summary>
        /// 自增ID
        /// </summary>
        [Display(Name = "自增ID")]
        public long Id { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [Display(Name = "创建人")]
        [StringLength(128)]
        public string? AddBy { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        public DateTime AddTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新人
        /// </summary>
        [Display(Name = "更新人")]
        [StringLength(128)]
        public string? UpdateBy { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        [Display(Name = "更新时间")]
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 已删除：0否1是
        /// </summary>
        [Display(Name = "状态")]
        [Range(0, 9)]
        public byte IsDelete { get; set; } = 0;

        /// <summary>
        /// 已使用数量
        /// </summary>
        [Display(Name = "已使用数量")]
        public int UseCount { get; set; } = 0;

        /// <summary>
        /// 已领取数量
        /// </summary>
        [Display(Name = "已领取数量")]
        public int ReceiveCount { get; set; } = 0;

        /// <summary>
        /// 店铺名称
        /// </summary>
        [Display(Name = "店铺名称")]
        public string? MerchantTitle { get; set; }
    }

    /// <summary>
    /// 优惠券(编辑)
    /// </summary>
    public class ShopCouponEditDto
    {
        /// <summary>
        /// 所属商户ID
        /// </summary>
        [Display(Name = "所属商户")]
        public int MerchantId { get; set; }

        /// <summary>
        /// 类型0店铺券1商品券
        /// </summary>
        [Display(Name = "优惠券类型")]
        public byte UseType { get; set; } = 0;

        /// <summary>
        /// 优惠券名称
        /// </summary>
        [Display(Name = "优惠券名称")]
        [Required(ErrorMessage = "{0}不可为空")]
        [StringLength(128)]
        public string? Title { get; set; }

        /// <summary>
        /// 优惠券面额
        /// </summary>
        [Display(Name = "优惠券面额")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal Amount { get; set; } = 0M;

        /// <summary>
        /// 门槛金额0不限制
        /// </summary>
        [Display(Name = "门槛金额")]
        [Column(TypeName = "decimal(18, 2)")]
        public decimal MinAmount { get; set; } = 0M;

        /// <summary>
        /// 兑换积分
        /// </summary>
        [Display(Name = "兑换积分")]
        public int Point { get; set; } = 0;

        /// <summary>
        /// 发行数量
        /// </summary>
        [Display(Name = "发行数量")]
        public int PublishCount { get; set; }

        /// <summary>
        /// 可以领取时间
        /// </summary>
        [Display(Name = "领取时间")]
        public DateTime EnableTime { get; set; }

        /// <summary>
        /// 开始使用时间
        /// </summary>
        [Display(Name = "开始时间")]
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 结束使用时间
        /// </summary>
        [Display(Name = "结束时间")]
        public DateTime EndTime { get; set; }


        /// <summary>
        /// 商品关联列表
        /// </summary>
        public ICollection<ShopCouponGoodsRelationDto> GoodsRelations { get; set; } = new List<ShopCouponGoodsRelationDto>();
    }
}
